/* -*- indent-tabs-mode:T; c-basic-offset:8; tab-width:8; -*- vi: set ts=8:
 * $Id: fast_matrix.h,v 1.1 2004/09/12 03:40:39 poine Exp $
 *
 * mult_op is a multipurpose operation that will perform the following
 * expressions:
 *
 *	OUT  = A * B
 *	OUT  = A * B'
 *	OUT += A * B
 *	OUT += A * B'
 *	OUT -= A * B
 *	OUT -= A * B'
 *
 * (c) 2003 Trammell Hudson <hudson@rotomotion.com>
 *
 *************
 *
 *  This file is part of the autopilot onboard code package.
 *  
 *  Autopilot is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *  
 *  Autopilot is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *  
 *  You should have received a copy of the GNU General Public License
 *  along with Autopilot; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */

#ifndef _fast_matrix_h_
#define _fast_matrix_h_

#ifdef __cplusplus
#include <mat/Matrix.h>
#endif

#include <macros.h>


BEGIN_DECLS

extern void
multNxMxP(
	void *		out,
	const void *	A,
	const void *	B,
	int		n,
	int		m,
	int		p,
	int		operation,
	int		transpose_B
);

END_DECLS


#ifdef __cplusplus

namespace libmat
{

template<
	int			n,
	int			m,
	int			p
>
void
mult_op(
	Matrix<n,p> &		OUT,
	int			operation,
	const Matrix<n,m> &	A,
	const Matrix<m,p> &	B
)
{
	multNxMxP(
		OUT.array(),
		A.array(),
		B.array(),
		n,
		m,
		p,
		operation,
		0
	);
}

template<
	int			n,
	int			m,
	int			p
>
void
mult_op_tr(
	Matrix<n,p> &		OUT,
	int			operation,
	const Matrix<n,m> &	A,
	const Matrix<p,m> &	B
)
{
	multNxMxP(
		OUT.array(),
		A.array(),
		B.array(),
		n,
		m,
		p,
		operation,
		1
	);
}

};
#endif

#endif
